def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True

def next_prime(num):
    while True:
        if is_prime(num):
            return num
        num += 1

def word_to_number(word):
    numbers = {
        "zero": 0, "one": 1, "two": 2, "three": 3,
        "four": 4, "five": 5, "six": 6, "seven": 7,
        "eight": 8, "nine": 9
    }
    return numbers.get(word)

def main():
    words = input("Введите три слова: ").split()
    
    if len(words) != 3:
        print("Wrong input")
        return
    
    number = int(''.join(str(word_to_number(word)) for word in words))
    
    if 100 <= number <= 999:
        result = next_prime(number)
        print(result)
    else:
        print("Wrong input")

if __name__ == "__main__":
    main()
